public class L242 {

    public static void main(String[] args) {
        String s = "anagram";
        String t = "nagaram";

        boolean flag = new Solution().isAnagram(s, t);
        System.out.println(flag);
    }

    static class Solution {
        public boolean isAnagram(String s, String t) {

            int[] record = new int[26];

            for (int i = 0; i < s.length(); i++) {
                record[s.charAt(i) - 'a']++;
            }

            for (int i = 0; i < t.length(); i++) {
                record[t.charAt(i) - 'a']--;
            }

            for (int j : record) {
                if (j != 0) {
                    return false;
                }
            }
            return true;
        }
    }
}
